package com.wuyong.chapter7;

import com.wuyong.chapter6.BinarySearchTree;

/**
 * 底层用二分搜索树实现Set集合
 * @param <E>
 */
public class BSTSet<E  extends Comparable<E>> implements Set<E> {

    private BinarySearchTree binarySearchTree;

    public BSTSet() {
        binarySearchTree = new BinarySearchTree();
    }
    @Override
    public void add(E e) {
        binarySearchTree.add(e);
    }

    @Override
    public void remove(E e) {
        binarySearchTree.remove(e);
    }

    @Override
    public boolean contains(E e) {
        return binarySearchTree.contains(e);
    }

    @Override
    public int getSize() {
        return binarySearchTree.size();
    }

    @Override
    public boolean isEmpty() {
        return binarySearchTree.isEmpty();
    }

    @Override
    public String toString() {
        return binarySearchTree.toString();
    }
}
